/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.jvn.ts.control;

import edu.jvn.ts.dto.ObjectPosition;
import edu.jvn.ts.util.SimulationGenerator;
import javax.jws.WebMethod;
import javax.jws.WebService;

/**
 *
 * @author HUNGPT
 */
@WebService()
public class SpeedMappingWS {

     /**
     * Web service operation
     */
    /*@WebMethod(operationName = "getLastestInformation")
    public int checkUserName(@WebParam(name = "userName") String userName) {

    }*/


    public ObjectPosition[] arrObjectPosition = {
        new ObjectPosition(10.765607,106.681921),
        new ObjectPosition(10.765686,106.682002),
        new ObjectPosition(10.76586,106.682136),
        new ObjectPosition(10.766197,106.682423),
        new ObjectPosition(10.766303,106.682527),
        new ObjectPosition(10.766411,106.682611),
        new ObjectPosition(10.766906,106.683058),
        new ObjectPosition(10.76791,106.684),
        new ObjectPosition(10.76815,106.684241),
        new ObjectPosition(10.768248,106.684341),
        new ObjectPosition(10.769312,106.685311),
        new ObjectPosition(10.770034,106.686004),
        new ObjectPosition(10.771133,106.68702),
        new ObjectPosition(10.771309,106.687181),
        new ObjectPosition(10.772527,106.688353),
        new ObjectPosition(10.77328,106.689069),
        new ObjectPosition(10.773354,106.68915),
        new ObjectPosition(10.773488,106.689244),
        new ObjectPosition(10.774176,106.689885),
        new ObjectPosition(10.775776,106.691424),
        new ObjectPosition(10.778168,106.693661),
        new ObjectPosition(10.779103,106.69452),
        new ObjectPosition(10.779169,106.694592),
        new ObjectPosition(10.77924,106.694654),
        new ObjectPosition(10.779414,106.694817),
        new ObjectPosition(10.779543,106.69493),
        new ObjectPosition(10.780431,106.695743)
    };


    public static int index = 0;

    /**
     * Web service operation
     */
    @WebMethod(operationName = "getLastestInformation")
    public String getLastestInformation() {

       int state;
       SimulationGenerator simulationGenerator = new SimulationGenerator();
       int speed = simulationGenerator.random(0, 80);

       if(speed <=5){
           state = 0;
       }else if(speed >=40){
           state = 2;
       }else{
           state = 1;
       }

       index++;
       if(index == 27) index =0;
       
       return arrObjectPosition[index].getLatitude() + "," +  arrObjectPosition[index].getLongtitude() + ", " + Integer.toString(state);


    }

}
